﻿Imports ajayumi.develop.win32.Monster.Base

Public Class ActionManager
    Inherits ActionManagerBase

    Private m_WorkFlowList As List(Of ActionType) = Nothing

    Public Sub New()
        Me.m_WorkFlowList = New List(Of ActionType)()

        With Me.m_WorkFlowList
            .Add(ActionType.Normal)
            .Add(ActionType.RunLeft)
            .Add(ActionType.RunRight)
            .Add(ActionType.DrawHeartShaped)
            .Add(ActionType.RunRight)
            .Add(ActionType.RunLeft)
            .Add(ActionType.Normal)
            .Add(ActionType.Disrobe)
            .Add(ActionType.Bathe)
            .Add(ActionType.SayLove)
            .Add(ActionType.Dress)
            '.Add(ActionType.Goodbye)
        End With
    End Sub

    Public Overrides Function [Next]() As ActionBase
        Dim _Action As ActionBase = Nothing
        If Me.m_ActionDic Is Nothing OrElse Me.m_ActionDic.Count = 0 Then
            Return _Action
        End If

        If Me.m_Index >= Me.m_WorkFlowList.Count Then
            Me.m_Index = 0
        End If

        _Action = Me.m_ActionDic(Me.m_WorkFlowList(Me.m_Index).ToString())
        Me.m_Index += 1

        Return _Action
    End Function

    Public Overrides Sub [Exit]()
        MyBase.Exit()

        Dim _Action As ActionBase = Nothing
        Dim _RunActions = From _RunAction In Me.m_ActionDic.Values _
                          Where _RunAction.IsBusy = True _
                          Select _RunAction
        For Each _Action In _RunActions
            _Action.Stop()
        Next

        _Action = Me.m_ActionDic(ActionType.Goodbye.ToString())
        _Action.Play()
    End Sub

End Class
